const path = require("path");

var fs = require('fs');

// 统计webpack不打包的模块，遍历加载除.bin的所有模块
var nodeModules = {};
fs.readdirSync('node_modules')
  .filter(function(x) {
    return ['.bin'].indexOf(x) === -1;
  })
  .forEach(function(mod) {
    nodeModules[mod] = 'commonjs ' + mod;
  });

module.exports = {

  target: 'node',
  mode: 'production',
  // mode: 'development',
  entry: './functions/js_use_java.coffee',

  output: {
    path: path.join(__dirname, 'dist/functions'),
    filename: 'js_use_java.js'
  },
  // node: {
  //   __dirname: false,
  //   __filename: false,
  // },
  // externals: nodeModules,

  module: {
    rules: [
      {
        test: /\.coffee$/,
        loader: 'coffee-loader',
        exclude: /node_modules/
      }
    ]
  },

  // optimization: {
  //   minimize: true,
  // },
  
  // resolve:{
    // extensions: [".coffee", ".json" , '.js'],
    // alias: {
    //   'nanoid/generate' : path.resolve(__dirname, 'node_modules/nanoid/generate.js'),
    //   '@typegoose/auto-increment': path.resolve(__dirname, 'node_modules/@typegoose/auto-increment/lib/autoIncrement.js')
    // }
  // }

}


